function touch_(touch_) {
	var startX, startY, endX, endY
	$(touch_).bind("touchstart", function(e) {
		if(e.cancelable) {
			// 判断默认行为是否已经被禁用
			/*if(!e.defaultPrevented) {
				e.preventDefault();
			}*/
		}
		startX = e.originalEvent.changedTouches[0].pageX,
			startY = e.originalEvent.changedTouches[0].pageY;
		//alert(startX)
	})
	$(touch_).bind("touchend", function(e) {
		if(e.cancelable) {
			// 判断默认行为是否已经被禁用
			/*if(!e.defaultPrevented) {
				e.preventDefault();
			}*/
		}
		endX = e.originalEvent.changedTouches[0].pageX,
			endY = e.originalEvent.changedTouches[0].pageY;
		var left = startX - endX;
		if(left > 15) {
			bind_next(1)
		} else if(left < -15) {
			bind_next(0)
		}
		})
}

function bind_next (x) {
	var classList=[".username",".phone"];
	var activeList=[""]
	if(x==0){
		$(classList[x]).css("display","block");
		$(".head div:first-child").addClass("active");
		$(classList[1]).css("display","none");
		$(".head div:last-child").removeClass("active");
	}else if(x==1){
		$(classList[x]).css("display","block");
		$(".head div:last-child").addClass("active");
		$(classList[0]).css("display","none");
		$(".head div:first-child").removeClass("active");
	}else{
		return false;
	}
}

function checkUserForm(e){
	var password=$("#password")
	if(!$.trim($("#user").val())||!$.trim(password.val())){
		alert("账号或者密码不能为空")
		return false;
	}else{
		return true;
	}
	
}
function checkPhoneForm(e){
	var verify=$("#verify")
	var phoneNum=$("#phoneNum")
	if(!$.trim(verify.val())){
		alert("验证码不能为空")
		return false;
	}else if(!$.trim(phoneNum.val())||isNaN(phoneNum.val())||phoneNum.val().length!=11){
		alert("手机号格式不合法")
		return false;
	}
	return true;
}
function onclickDisplayBlock(e){
	var targetClass=$(e).attr("href")
//	alert(targetClass)
	$(".head div").removeClass("active");
	$("form").css("display","none");
	$(targetClass).css("display","block")
//	alert(e)
	$(e).addClass("active");
}

//显示密码
function showPassword(){
	var oPass=$("#password");
	if(oPass.attr("type")=="password"){
		oPass.attr("type","text")
		$("#showPass img").attr("src","img/fanzone_icon/showPassword.png"); 
	}else if(oPass.attr("type")=="text"){
		oPass.attr("type","password")
		$("#showPass img").attr("src","img/fanzone_icon/hidePassword.png"); 
	}
}
$(document).ready(function(){
	touch_("body")
})